package com.tencent.sr.iris.basic.mp.dependency;

import com.alibaba.fastjson.JSON;
import com.tencent.sr.iris.basic.service.interfaces.client.IrisCommonKvConfigClient;
import com.tencent.sr.iris.basic.service.interfaces.dto.TCommonKvConfigDTO;
import com.tencent.sr.iris.basic.service.interfaces.request.TCommonKvConfigAddRequest;
import com.tencent.sr.iris.basic.service.interfaces.request.TCommonKvConfigBatchQueryRequest;
import com.tencent.sr.iris.basic.service.interfaces.request.TCommonKvConfigDeleteRequest;
import com.tencent.sr.iris.basic.service.interfaces.request.TCommonKvConfigQueryPageRequest;
import com.tencent.sr.iris.basic.service.interfaces.request.TCommonKvConfigUpdateRequest;
import com.tencent.sr.rmall.common.primitive.HttpResult;
import com.tencent.sr.rmall.common.response.PaginationResponse;
import com.tencent.sr.rmall.material.interfaces.request.PaginationRequest;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;

/**
 * @author xiaojun
 */
@Component
@Slf4j
public class IrisCommonKvConfigDependency {

    @Resource
    private IrisCommonKvConfigClient irisCommonKvConfigClient;

    /**
     * 查询kv配置 toC，10s缓存
     *
     * @param request
     * @return
     */
    public HttpResult<List<TCommonKvConfigDTO>> batchQueryCommonKV(TCommonKvConfigBatchQueryRequest request){
        try {
            return irisCommonKvConfigClient.batchQueryCommonKV(request);
        } catch (Exception e) {
            log.error("batchQueryCommonKV error,request:{}", JSON.toJSONString(request), e);
            return HttpResult.fail(e.getMessage());
        }
    }

//    /**
//     * 查询kv配置 无缓存
//     *
//     * @param request
//     * @return
//     */
//    @ApiOperation("查询kv配置，无缓存（B端调用）")
//    @PostMapping("/batchQueryCommonKVNoCache")
//    HttpResult<List<TCommonKvConfigDTO>> batchQueryCommonKVNoCache(TCommonKvConfigBatchQueryRequest request){
//        try {
//            return irisCommonKvConfigClient.batchQueryCommonKVNoCache(request);
//        } catch (Exception e) {
//            log.error("batchQueryCommonKVNoCache error,request:{}", JSON.toJSONString(request), e);
//            return HttpResult.fail(e.getMessage());
//        }
//    }
}
